<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="classes/conndb.jsp"%>

<%
     PreparedStatement ps= null;
     Connection con =null;
     ResultSet rs=null;
    
     String message_id = request.getParameter("message_id") == null ? "" : request.getParameter("message_id");
	 String is_public = request.getParameter("is_public") == null ? "" : request.getParameter("is_public");
	 String answer_content = request.getParameter("answer_content") == null ? "" : request.getParameter("answer_content");
	 String answer_time = request.getParameter("answer_time") == null ? "" : request.getParameter("answer_time");
	 String submit_time = request.getParameter("submit_time") == null ? "" : request.getParameter("submit_time");
    
	String upsql1 = "update cms_reply_comment set content=?,operate_time=to_date(?, 'yyyy-mm-dd hh24:mi:ss'),is_public=? where message_id=?";
	String upsql2 = "update cms_public_comment set is_public =?,operate_time=to_date(?, 'yyyy-mm-dd hh24:mi:ss') where message_id =?";
	
    int count1 =0;
    int count2 =0;
    
    try{
    	con=getConnection();
    	ps=con.prepareStatement(upsql1);
    	ps.setObject(1, answer_content);
    	ps.setObject(2, answer_time);
    	ps.setObject(3, is_public);
    	ps.setObject(4, message_id);
    	count1 =ps.executeUpdate();
    	
    	ps=con.prepareStatement(upsql2);
    	ps.setObject(1, is_public);
    	ps.setObject(2, submit_time);
    	ps.setObject(3, message_id);
    	count2 =ps.executeUpdate();
    	   	
    }catch(Exception e){
		e.printStackTrace();
	}finally{
		closeConn(con,ps,rs);
	}
    if (count1 > 0 && count2 > 0) {
        out.print("{\"operate_status\":\"1\"}");
    } else {
        out.print("{\"operate_status\":\"0\"}");
    }


%>